<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>Plot a polar plot of an antenna array sensitivity</title>
<link rel="canonical" href="http://cvxr.com/cvx/examples/antenna_array_design/html/polar_plot_ant.html">
<link rel="stylesheet" href="../../examples.css" type="text/css">
</head>
<body>
<div id="header">
<h1>Plot a polar plot of an antenna array sensitivity</h1>
Jump to:&nbsp;&nbsp;&nbsp;&nbsp;
<a href="#source">Source code</a>&nbsp;&nbsp;&nbsp;&nbsp;
Text output
&nbsp;&nbsp;&nbsp;&nbsp;
Plots
&nbsp;&nbsp;&nbsp;&nbsp;<a href="../../index.html">Library index</a>
</div>
<div id="content">
<a id="source"></a>
<pre class="codeinput">
<span class="comment">% with lines denoting the target direction and beamwidth.</span>
<span class="comment">% This is a helper function used in the broadband antenna examples.</span>
<span class="comment">%</span>
<span class="comment">% Inputs:</span>
<span class="comment">%    X:      an array of abs(y(theta)) where y is the antenna array pattern</span>
<span class="comment">%    theta0: target direction</span>
<span class="comment">%    bw:     total beamwidth</span>
<span class="comment">%    label:  a string displayed as the plot legend</span>
<span class="comment">%</span>
<span class="comment">% Original code by Lieven Vandenberghe</span>
<span class="comment">% Updated for CVX by Almir Mutapcic 02/17/06</span>

<span class="keyword">function</span> polar_plot_ant(X,theta0,bw,label)

<span class="comment">% polar plot</span>
numpoints = length(X);
thetas2 = linspace(1,360,numpoints)';

plot(X.*cos(pi*thetas2/180), X.*sin(pi*thetas2/180), <span class="string">'-'</span>);
plot(X.*cos(pi*thetas2/180), X.*sin(pi*thetas2/180), <span class="string">'-'</span>);
hold <span class="string">on</span>;
axis(<span class="string">'equal'</span>);

plot(cos(pi*[thetas2;1]/180), sin(pi*[thetas2;1]/180), <span class="string">'--'</span>);
text(1.1,0,<span class="string">'1'</span>);

plot([0 cos(pi*theta0/180)], [0 sin(pi*theta0/180)], <span class="string">'--'</span>);
sl1 = find(thetas2-theta0 &gt; bw/2);
sl2 = find(thetas2-theta0 &lt; -bw/2);
Gsl = max(max(X(sl1)), max(X(sl2)));
plot(Gsl*cos(pi*thetas2(sl1)/180), Gsl*sin(pi*thetas2(sl1)/180), <span class="string">'--'</span>);
plot(Gsl*cos(pi*thetas2(sl2)/180), Gsl*sin(pi*thetas2(sl2)/180), <span class="string">'--'</span>);

text(-1,1.1,label);

axis <span class="string">off</span>;
</pre>
</div>
</body>
</html>